<?php

if(!empty($_POST['to'])&&!empty($_POST['from'])&&!empty($_POST['contant'])){
	$res=send_message($_POST['from'],$_POST['to'],$_POST['contant']);
	if($res){
		echo "success";
		exit();
	}
	else{
		echo "failed";
		exit();
	}
}

$can_send=false;
if($userid!=-1 && !empty($_GET["to"])){
	$can_send=true;
}

?>

<script type="text/javascript">register_sendmsg();</script>
<div id='senddiag'>
<div id='sendto'>
<?php 
    if($can_send){
    	echo "发送消息给　".get_user_name_by_id($_GET["to"]);
    }
    else{
    	echo "无效的用户或者发送对象";
    }
?>
</div>
<div id='sendtip'></div>
<div id='sendcontant'>
<textarea rows=10 cols=79 class="msgcontant" name="msgcontant" <?php if(!$can_send){echo "disabled=disabled";}?>></textarea>
</div>
<div id='sendcontrol'>
<input type="hidden" class='to' value='<?php echo $_GET['to'];?>'>
<input type="hidden" class='from' value='<?php echo $userid?>'>
<input type="button" class='send_msg' value='发送' <?php if(!$can_send){echo "disabled=disabled";}?>>
</div>
</div>